package com.raisecom.redis;

import org.apache.log4j.Logger;

import redis.clients.jedis.Jedis;

/**
 * 客戶端工具类
 * @author root
 */
public class JRedisClientUtil {
    private static Logger log = Logger.getLogger(JRedisClientUtil.class);

    /**
     * push新的记录
     * @param key
     * @param value
     */
    public static void lpushFile(String key,String value){
        Jedis ji = JRedisPoolUtil.getJedisPool();
        ji.lpush(key, value);
        JRedisPoolUtil.returnJedisPool(ji);
    }
    
    /**
     * 读取已经存储的记录
     * @param key
     * @return
     */
    public static String rpopFile(String key){
        Jedis ji = JRedisPoolUtil.getJedisPool();
        String r = ji.rpop(key);
        JRedisPoolUtil.returnJedisPool(ji);
        return r;
    }
    
    public static void main(String[] args) {
    	Jedis ji = JRedisPoolUtil.getJedisPool();
    	for (int i = 0; i < 10; i++) {
//    		JRedisClientUtil.lpushFile("test", "test");
//    		ji.set("test", "test");
    		ji.del("test" + i);
//    		ji.set("test" + i, "test" + i);
    	}
    	JRedisPoolUtil.returnJedisPool(ji);
    	
//    	String info = JRedisClientUtil.rpopFile("test");
//    	System.out.println(info);
	}
}
